package com.cskaoyan.market.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.support.TransactionTemplate;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;

/**
 * @ClassName SpringConfig
 * @Description: TODO
 * @Author 远志 zhangsong@cskaoyan.onaliyun.com
 * @Date 2023/5/18 17:13
 * @Version V1.0
 **/
@Configuration
@EnableTransactionManagement
public class SpringConfig {

    @Autowired
    fileTransfer fileTransfer;

    @Autowired
    ServletContext servletContext;
    @Bean
    public void fileTransferData(){
        servletContext.setAttribute("upload",fileTransfer.getUploadBasePath());
        servletContext.setAttribute("domain",fileTransfer.getDomain());
//        System.out.println(servletContext.getAttribute("upload"));
    }
    @Bean
    public TransactionTemplate transactionTemplate(PlatformTransactionManager platformTransactionManager){
        return new TransactionTemplate(platformTransactionManager);
    }
}
